package cn.simonfish.carrier.controller.view;

import cn.simonfish.carrier.common.Dict;
import cn.simonfish.carrier.controller.BaseController;
import com.jfinal.kit.StrKit;
import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Record;

import java.util.List;

/**
 * Created by simon on 2017/10/3.
 */
public class BuyView extends BaseController {

    /**
     * 选择网站页面
     * */
    public void select(){
        String region = getPara("region");
        List<Record> siteList = null;
        String sql = "select REGION,WEBSITE from  SETTING_WEBSITE";
        if(StrKit.isBlank(region)){
            siteList = Db.find(sql);
        }else {
            siteList = Db.find(sql+" where REGION=?",region);
        }
        setAttr("siteList",siteList);
        setAttr("regions",Db.find("select REGION from  SETTING_WEBSITE group by REGION"));
        renderFreeMarker("/template/buy/select.html");
    }

    /**
     * 选择套餐
     */
    public void combo(){
        setAttr("combos", Dict.get("combo"));
        String[] sites = getParaValues("site");
        setAttr("sites",sites);
        renderFreeMarker("/template/buy/combo.html");
    }


}
